import Vue from 'vue'
import VueRouter from 'vue-router'
import Footer from '@/components/footer.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home', // 地址栏输入的那个网址
    name: 'home', // 起的名字 -- 命名路由
    // 当前地址栏输入这个网址时，你需要显示的是哪一个页面
    // 路由的懒加载
    components: {
      default: () => import('@/views/home/index'), // 注册的默认组件
      footer: Footer // 按需按需加载的组件,需要显示就注册不需要显示就不注册
    }
  },
  {
    path: '/kind/:type',
    name: 'kind',
    components: {
      default: () => import('@/views/kind/index'),
      footer: Footer
    }
  },
  {
    path: '/wallet',
    name: 'wallet',
    components: {
      default: () => import('@/views/wallet/index'),
      footer: Footer
    }
  },
  {
    path: '/user',
    name: 'user',
    components: {
      default: () => import('@/views/user/index'),
      footer: Footer
    }
  },
  {
    path: '/login',
    name: 'login',
    components: {
      default: () => import('@/views/login/index')
    }
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register/index.vue')
  },
  {
    path: '/detail',
    name: 'detail',
    component: () => import('@/views/detail/index.vue')
  },
  {
    path: '/vip',
    name: 'vip',
    component: () => import('@/views/vip/index.vue')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search/index.vue')
  },
  {
    path: '/changePwd',
    name: 'changePwd',
    component: () => import('@/views/changePwd/index.vue')
  },
  {
    path: '/changeMsg',
    name: 'changeMsg',
    component: () => import('@/views/changeMsg/index.vue')
  },
  {
    path: '/setting',
    name: 'setting',
    component: () => import('@/views/setting/index.vue')
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import('@/views/cart/index.vue')
  },
  {
    path: '/addressList',
    name: 'addressList',
    component: () => import('@/views/addressList/index.vue')
  },
  {
    path: '/addressAdd',
    name: 'addressAdd',
    component: () => import('@/views/addressAdd/index.vue')
  },
  {
    path: '/myOrder',
    name: 'myOrder',
    component: () => import('@/views/myOrder/index.vue')
  },
  {
    path: '/orderDetails',
    name: 'orderDetails',
    component: () => import('@/views/orderDetails/index.vue')
  },
  {
    path: '/realName',
    name: 'realName',
    component: () => import('@/views/realName/index.vue')
  },
  {
    path: '/address',
    name: 'address',
    component: () => import('@/views/address/index.vue')
  },
  {
    path: '/updataAddress',
    name: 'updataAddress',
    component: () => import('@/views/updataAddress/index.vue')
  },
  {
    path: '/realNameAdd',
    name: 'realNameAdd',
    component: () => import('@/views/realNameAdd/index.vue')
  },
  {
    path: '/cardBag',
    name: 'cardBag',
    component: () => import('@/views/cardBag/index.vue')
  },
  {
    path: '*',
    name: 'notfound',
    component: () => import('@/views/notfound/index.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
